package array;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class test3{
    public static void main(String[] args) {
        String inputFile = "D:\\test\\Hilbert_spatial_keyword_query\\set\\ds1\\PGPS.txt"; // 输入文件的路径
        String outputFile = "D:\\test\\Hilbert_spatial_keyword_query\\set\\ds1\\PGPS111.txt"; // 输出文件的路径

        try (BufferedReader reader = new BufferedReader(new FileReader(inputFile));
             FileWriter writer = new FileWriter(outputFile)) {

            String line;
            while ((line = reader.readLine()) != null) {
                String[] parts = line.split(","); // 使用逗号分割行
                if (parts.length > 1) { // 确保行包含至少两个部分
                    StringBuilder newLine = new StringBuilder();
                    for (int i = 1; i < parts.length; i++) { // 从第二部分开始
                        newLine.append(parts[i]);
                        if (i < parts.length - 1) { // 如果不是最后一部分，添加空格
                            newLine.append(" ");
                        }
                    }
                    writer.write(newLine.toString()); // 写入新行
                    writer.write("\n"); // 写入新行
                }
            }
        } catch (IOException e) {
            System.err.println("Error reading or writing files: " + e.getMessage());
        }
    }
}
